import request from '@/utils/request'

export default {
  //问题列表显示
  getAllListByPage(page, size) {
    return request({
      url: `/forumservice/forum-question/questionList/${page}/${size}`,
      method: 'get'
    })
  },

  //发起问题
  addQuestion(question) {
    return request({
      url: `/forumservice/forum-question/editQuestion/addQuestion`,
      method: 'post',
      data: question
    })
  },

  //根据话题ID获取话题信息
  getQuestionById(questionId) {
    return request({
      url: `/forumservice/forum-question/getQuestionById/` + questionId,
      method: 'get'
    })
  },

  //markdown 编辑器，上传图片
  uploadOssFile(file) {
    return request({
      url: '/eduoss/fileoss/uploadFile',
      method: 'post',
      data: file,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },
  
  //得到评论列表
  getList(questionId, parentId, userDesc) {
    return request({
      url: `/forumservice/forum-comment/getList/${questionId}/${parentId}/${userDesc}`,
      method: 'get',
    })
  },

  //在一级列表或二级列表处评论
  replyOperatorInFirstLeve(replyInFirstLevelVo) {
    return request({
      url: '/forumservice/forum-comment/replyOperatorInFirstLeve',
      method: 'post',
      data: replyInFirstLevelVo
    })
  },

  //点赞
  likeOperator(forumCommentId) {
    return request({
      url: '/forumservice/forum-comment/likeOperator/' + forumCommentId,
      method: 'post'
    })
  },

  //取消点赞
  cancelLikeOperator(forumCommentId) {
    return request({
      url: '/forumservice/forum-comment/cancelLikeOperator/' + forumCommentId,
      method: 'post'
    })
  },

  //获取话题总评论数
  getCommentCount(questionId) {
    return request({
      url: `/forumservice/forum-question/getCommentCount/${questionId}`,
      method: 'get',
    })
  },

  //根据标签获取相关话题
  relatedQuestion(questionId, tags) {
    return request({
      url: `/forumservice/forum-question/relatedQuestion/${questionId}/${tags}`,
      method: 'get',
    })
  },

  //修改问题
  updateQuestion(updateQuestionVo) {
    return request({
      url: `/forumservice/forum-question/editQuestion/updateQuestion`,
      method: 'post',
      data: updateQuestionVo
    })
  },

  //根据condition条件(这里的condition要和数据库字段对应上)获取热门话题
  hotTopic(condition) {
    return request({
      url: `/forumservice/forum-question/hotTopic/${condition}/`,
      method: 'get',
    })
  },

  //搜索话题
  questionListByKeyWords(keyWords, page, size) {
    return request({
      url: `/forumservice/forum-question/questionListByKeyWords/${keyWords}/${page}/${size}`,
      method: 'get'
    })
  },

  //评论或回复时，通知接收人(插入记录)
  addNotification(forumNotification) {
    return request({
      url: `/forumservice/forum-notification/addNotification`,
      method: 'post',
      data: forumNotification
    })
  },

  //根据userId 查询消息通知(分页)
  getNotificationList(userId, page, size) {
    return request({
      url: `/forumservice/forum-notification/notificationList/${userId}/${page}/${size}`,
      method: 'get'
    })
  },

  //修改状态为已读
  updateStatus(notificationId) {
    return request({
      url: `/forumservice/forum-notification/updateStatus/${notificationId}/`,
      method: 'post'
    })
  },

}